package Comp;

import java.awt.*;

import javax.swing.*;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;


import UI_Comp.ImageComponent;

public class daehee_comp extends JPanel{
	
	public static JPanel DHchart(String row[], String col[]){
		JFreeChart chart = setChart(setDataset(row, col));
        
        ChartPanel retChartPanel = new ChartPanel(chart);
        retChartPanel.setPreferredSize(new Dimension(240,220));
        
        return retChartPanel;
	}
	
	private static DefaultCategoryDataset setDataset(String row[], String col[]) {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
       
        for(int i = 0; i < 3; i++)
			for(int j = 0; j < 5; j++)
				dataset.addValue((int)(Math.random()*20)-10, row[i], col[j]);
		                
        return dataset;
    }
	
	private static JFreeChart setChart(DefaultCategoryDataset dataset) {
        final JFreeChart chart = ChartFactory.createBarChart(
        		"dh Bar Chart",
        		"column Category",
        		"row Value",
        		dataset,
        		PlotOrientation.VERTICAL,
        		true,
        		true,
        		false
        );
        chart.setBackgroundPaint(Color.GRAY);
        chart.setBorderVisible(true);
        chart.setBorderPaint(Color.BLACK);
        chart.setBorderStroke(new BasicStroke(3));
        
        return chart;
	}
}